/**
 * @author Steve Gao<gaofu@parllay.com>
 */
const BaseHandler     = require('../base-handler');
const HTTP_VERBS      = require('../../../constants').HTTP_VERBS;

class WallHandler extends BaseHandler {

    get pattern() {
        return '/me/walls/:wall_id';
    }

    doGET(request, response) {
    
        if(!request.session.user.authenticated) {
            response.end(JSON.stringify({}));
        } else {
            this.Controller.getWallById(request.params.wall_id, (data) => {
                data.description = unescape(data.description);
                data.tag = escape(data.tag);
                response.json(data);
            });
        }
    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
    }
}

module.exports = WallHandler;